﻿using System.Configuration;
using System.Web.Http;
using FellowshipOne.API;
using FellowshipOne.API.Base;

namespace MasVida.WebApi.Controllers.Interfaces
{
    public interface IApiBaseController
    {
        IFellowshipOneClient FellowshipOneClient { get; set; }
        IRestClient GetRestClient(F1OAuthTicket accessToken);
    }

    public abstract class ApiBaseController : ApiController, IApiBaseController
    {
        public IFellowshipOneClient FellowshipOneClient { get; set; }

        protected IRestClient RestClient { get; set; }

        public IRestClient GetRestClient(F1OAuthTicket accessToken)
        {
            return RestClient ?? new RestClient(accessToken, ConfigurationManager.AppSettings["API.Url"], true, true);
        }
        
    }
}
